package com.keepstudy.producer;

import com.keepstudy.constant.RabbitMQConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

/**
 * 消息生产者
 *
 * @author Shengkang.Mo
 * @create 2021-02-09 15:22
 */
@Slf4j
@Component
public class BusinessMessageSender {

    private final RabbitTemplate rabbitTemplate;

    public BusinessMessageSender(RabbitTemplate rabbitTemplate) {
        this.rabbitTemplate = rabbitTemplate;
    }

    public void sendMsg(String msg) {
        log.info("BusinessMessageSender sendMsg msg:{}", msg);
        rabbitTemplate.convertSendAndReceive(RabbitMQConstant.BUSINESS_EXCHANGE_NAME, "", msg);
    }
}
